Z80 and R800 Assembly/Machine Language Op-code Tables
Written by "Cyberknight" Masao Kawata.
E-Mail:
cyberknight@catsrule.garfield.com
Home Page :
http://welcome.to/unicorndreams
Revised: 1999-May-25
Tuesday.
These tables are compilations of different sources, including Z80 instruction set tables and an article of the Japanese "MSX Magazine" (issue of 1990-Nov.) with R800 Assembly.
Available tables:
Tables entries:
Flags: description of register F bits' reaction to the instruction execution:
. | (flag not modified) |
* | (flag modified by the instruction) |
0 | (flag reset), 1 (flag set) |
p | ("parity/overflow" flag indicates parity) |
o | ("parity/overflow" flag indicates overflow state) |
? | (flag result is officially undocumented) |
$ | (if .bc becomes zero, flag is set to 0, else to 1) |
% | (if .a = [.hl], then flag is set to 1, else to 0) |
! | (if .b becomes zero, flag is set to 1, else to 0) |
I | (copies the value of IFF into the flag) |
The flags are:
S | (sign, .f{7}) |
Z | (zero, .f{6}) |
H | (half-carry, .f{4}) |
P | (parity/overflow, .f{3}) |
N | (subtraction, .f{1}) |
C | (carry, .f{0}) |
* The time spent by each instruction depends on the hardware architecture. MSX uses RAS/CAS memory banks, so some "wait states" may be generated when accessing memory, even when just reading the program op-codes. MSX turbo R is somehow optimized so it avoids some wait-states when running in R800 mode.
Flag Results
The kind of modification each instruction makes on the flags depends on the results of the operation. Some of the most important results are:
Note that INC and DEC instructions for 16 bit registers don't affect any flag.
Definitions used in the tables:
Z80 8 bit registers | ||||||||
000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
r | b | c | d | e | h | l | a |
R800 8 bit registers | ||||||||
000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
r | .b | .c | .d | .e | .h | .l | .a | |
u | .b | .c | .d | .e | .ixh | .ixl | .a | |
v | .b | .c | .d | .e | .iyh | .iyl | .a | |
p | .ixh | .ixl | ||||||
q | .iyh | .iyl |
Z80 16 bit registers | ||||
00 | 01 | 10 | 11 | |
rr | bc | de | hl | af |
ss | bc | de | hl | sp |
pp | bc | de | ix | sp |
bc | de | iy | sp |
R800 16 bit registers | ||||
00 | 01 | 10 | 11 | |
rr | .bc | .de | .hl | .af |
ss | .bc | .de | .hl | .sp |
pp | .bc | .de | .ix | .sp |
.bc | .de | .iy | .sp |
Other Registers | ||
Z80 | R800 | Name |
i | .i | interrupt vector |
r | .r | refresh register |
pc | .pc | program counter |
Bits | |
{b} | bit b (3 bits number) |
{x..y} | bit range x..y |
IFF | interrupt flip-flop |
C | 1st bit of .f |
N | 2nd bit of .f |
P | 4th bit of .f |
H | 5th bit of .f |
Z | 7th bit of .f |
S | 8th bit of .f |
Index Register Modifiers (Z80/R800) | ||
Bin Hex |
DDH 11011101B |
FDH 11111101B |
ii | ix/.ix | iy/.iy |
Reset/Break Addresses | ||||||||
000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
k | 00H | 08H | 10H | 18H | 20H | 28H | 30H | 38H |
Symbolic operands | |
+ | add |
- | subtract |
¡Ñ | multiply |
¡Ò | divide |
<< | assign |
<=> | exchange |
< | less than |
> | greater than |
= | equal |
[n] | I/O port n |
[.c] | I/O port defined by .c |
[nn] | address pointer |
Numbers | |
n | 8 bits |
d | -128..+127 |
nn | 16 bits |
nnl | nn "LSB" |
nnh | nn "MSB" |
Logical Operations | |
¬ | not |
& | and |
# | or |
^ | xor |
Symbolic registers | |
ssl | ss LSB |
ssh | ss MSB |
rrl | rr LSB |
rrh | rr MSB |
iil | ii LSB |
iih | ii MSB |
pcl | pc/.pc LSB |
pch | pc/.pc MSB |
tmp | temporary |
Register F/.F | ||||||||
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
flag | S | Z | H | P | N | C |
Notes: